package dper.study.codes.concurrent.worker;

import dper.study.codes.concurrent.model.ProConBuffer;
import dper.study.codes.concurrent.model.ProConBufferWaitNotifyAll;
import org.apache.log4j.Logger;

/**
 * Created by leichen on 2017/3/20.
 */
public class Producer implements Runnable {
    Logger logger = Logger.getLogger(Producer.class) ;

    private ProConBuffer proConBuffer ;

    private volatile int countNum = 0 ;

    public Producer(ProConBuffer proConBuffer){
        this.proConBuffer = proConBuffer ;
    }

    public void run() {
        while(true){
            synchronized (this) {
                proConBuffer.set(countNum);
                countNum++;
                logger.info("countNum now is " + countNum);
            }
            Thread.yield();
        }
    }
}
